home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 May / Chip Mayıs 2001.iso / prog / share / 07 / ASPFusion / data1.cab / Script_Pages / Scripts / vdir.vbs < prev    next >
Encoding:
Text File  |  2001-03-25  |  1.9 KB  |  69 lines

  1. '-------------------------------------------------------------------------------------
  2. ' Program to create the virtual directory during installation
  3. ' Author :    ASPFusion Support
  4. ' Company :    Advanced Communications    
  5. '-------------------------------------------------------------------------------------
  6. Option Explicit
  7. on error resume next
  8. Dim oArgs, ArgNum
  9. Dim iisObj,vObj,iisObj2,vObj2
  10. Dim sPath
  11. Dim VDirName
  12. Dim DefaultPage
  13. Dim IPRestrict
  14. Dim Account
  15. Set oArgs = WScript.Arguments
  16. if oArgs.Count < 1 then
  17.     WScript.Echo "Invalid no of arguments" & CStr(oArgs.Count)
  18. else
  19.     sPath = oArgs(0)
  20.     VDirName = oArgs(1)
  21.     DefaultPage = oArgs(2)
  22.     Account = oArgs(3)
  23.     IPRestrict = oArgs(4)
  24.     Err.clear
  25.     set iisObj = GetObject("IIS://localhost/w3svc/1/ROOT")
  26.     if Err <> 0 then
  27.         WScript.Echo "Error: IIS Object could not be obtained"
  28.         WScript.Quit(1)
  29.     end if     
  30.     Set vObj = iisObj.Create("IIsWebVirtualDir",VDirName)
  31.     if Err <> 0 then
  32.         WScript.Quit(1)    
  33.     else
  34.     'now set the attributes for the virtual directory
  35.         vObj.Path = sPath
  36.         vObj.SetInfo
  37.         vObj.AccessRead = True
  38.         vObj.AccessWrite = True
  39.         vObj.AccessScript = True
  40.         vObj.AccessExecute = True
  41.         vObj.AuthAnonymous = True    
  42.         vObj.AppCreate "TRUE"
  43.         vObj.AppFriendlyName = "ASPFusion"         
  44.         vObj.AnonymousPasswordSync = True
  45.         if (Account <> "") then
  46.             vObj.AnonymousUserName = Account
  47.         end if
  48.         vObj.EnableDefaultDoc = True
  49.         vObj.DefaultDoc = DefaultPage
  50.         vObj.SetInfo
  51.         if Err <> 0 then
  52.             WScript.Echo "Error: Could not set properties"
  53.             WScript.Quit(1)            
  54.         end if 
  55.         'now set the attributes for ip restriction
  56.         if (IPRestrict <> "") then
  57.             Dim currentobj, sobj,path
  58.             dim proparray(0)
  59.             path ="IIS://localhost/W3SVC/1/ROOT/"&VDirName
  60.             proparray(0)=IPRestrict
  61.             Set currentobj=GetObject(path)
  62.             Set sobj=currentobj.IPSecurity
  63.             sobj.GrantByDefault = FALSE        
  64.             sobj.IPGrant=(proparray)
  65.             currentobj.IPSecurity=sobj
  66.             currentobj.SetInfo
  67.         end if
  68.     end if
  69. end if